package views;

import views.panels.PanelGeneral;
import logicBusiness.GradoBL;
import models.Grado;
import java.awt.BorderLayout;

/**
 *
 * @author JARR
 */

public class InterfazAdministrarGrado extends javax.swing.JFrame {

    /** Creates new form InterfazAdministrarGrado */
    public InterfazAdministrarGrado() {
        initComponents();
        PanelGeneral panel = new PanelGeneral();
        this.add(panel, BorderLayout.SOUTH);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        CBBuscarGrado = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        BActualizarCur = new javax.swing.JButton();
        CTNumCur = new javax.swing.JTextField();
        CTNumAsig = new javax.swing.JTextField();
        BActualizarAsig = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        CBBuscarGrado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CBBuscarGradoActionPerformed(evt);
            }
        });

        jLabel1.setText("Numero de cursos");

        jLabel2.setText("Numero de Asignaturas");

        BActualizarCur.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        BActualizarCur.setText("Actualizar");
        BActualizarCur.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BActualizarCurActionPerformed(evt);
            }
        });

        BActualizarAsig.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        BActualizarAsig.setText("Actualizar");
        BActualizarAsig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BActualizarAsigActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(CBBuscarGrado, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(CTNumCur, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(CTNumAsig))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(BActualizarAsig, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(BActualizarCur, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(CBBuscarGrado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel1)
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CTNumCur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BActualizarCur))
                .addGap(27, 27, 27)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CTNumAsig, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BActualizarAsig))
                .addContainerGap(32, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CBBuscarGradoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CBBuscarGradoActionPerformed

        GradoBL bo = new GradoBL();
        Grado g = bo.encontrarGrado(CBBuscarGrado.getSelectedIndex());
//        CTNumCur.setText(String.valueOf(g.getNumeroCursos()));
        CTNumAsig.setText(String.valueOf(g.getNumeroasignaturas()));

    }//GEN-LAST:event_CBBuscarGradoActionPerformed

    private void BActualizarCurActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BActualizarCurActionPerformed
        GradoBL bo = new GradoBL();
        Grado g = bo.actualizarGradoCursos(CBBuscarGrado.getSelectedIndex(), Integer.parseInt(CTNumCur.getText()));
    }//GEN-LAST:event_BActualizarCurActionPerformed

    private void BActualizarAsigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BActualizarAsigActionPerformed
        GradoBL bo = new GradoBL();
        Grado g = bo.actualizarGradoAsignaturas(CBBuscarGrado.getSelectedIndex(), Integer.parseInt(CTNumAsig.getText()));
    }//GEN-LAST:event_BActualizarAsigActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new InterfazAdministrarGrado().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BActualizarAsig;
    private javax.swing.JButton BActualizarCur;
    private javax.swing.JComboBox CBBuscarGrado;
    private javax.swing.JTextField CTNumAsig;
    private javax.swing.JTextField CTNumCur;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    // End of variables declaration//GEN-END:variables
}
